﻿<!--_meta 作为公共模版分离出去-->
<!DOCTYPE HTML>
<html>

<head>
	<meta charset="utf-8">
	<meta name="renderer" content="webkit|ie-comp|ie-stand">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
	<meta http-equiv="Cache-Control" content="no-siteapp" />
	<link rel="Bookmark" href="/favicon.ico">
	<link rel="Shortcut Icon" href="/favicon.ico" />
	<!--[if lt IE 9]>
<script type="text/javascript" src="lib/html5shiv.js"></script>
<script type="text/javascript" src="lib/respond.min.js"></script>
<![endif]-->
	<link rel="stylesheet" type="text/css" href="static/h-ui/css/H-ui.min.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/H-ui.admin.css" />
	<link rel="stylesheet" type="text/css" href="lib/Hui-iconfont/1.0.8/iconfont.css" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/skin/default/skin.css" id="skin" />
	<link rel="stylesheet" type="text/css" href="static/h-ui.admin/css/style.css" />
	<!--[if IE 6]>
<script type="text/javascript" src="lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
	<!--/meta 作为公共模版分离出去-->

	<title>推流地址获取</title>
</head>

<body>
	<div class="page-container">
		<div class="form form-horizontal" id="form-article-add">
			<div id="tab-system" class="HuiTab">
				<div class="tabCon">
					<div class="row cl">
						<label class="form-label col-xs-4 col-sm-2">SioeyeID：</label>
						<div class="formControls col-xs-8 col-sm-9">
							<input type="text" class="input-text" value="" id="sioeyeid"" name="" placeholder="SioeyeID">
						</div>
						<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-2">
							<button id="btn_apply" class="btn btn-primary radius" type="button">
								<i class="Hui-iconfont"></i>获取设备列表</button>
						</div>
					</div>
				</div>
			</div>
		</div>
		<div class="row cl">
			<table class="table table-border table-bordered table-bg">
				<thead>
					<tr>
						<th scope="col" colspan="11" id="video-title">设备列表</th>
					</tr>
					<tr class="text-c">
						<th width="230">userid</th>
						<th width="230">sioeyeid</th>
						<th width="100">deviceid</th>
						<th width="100">devicetypeid</th>
						<th width="210">devicename</th>
						<th width="200">sessiontoken</th>
						<th width="200">createdat</th>
						<th width="20">操作</th>
					</tr>
				</thead>
				<tbody id="list">

				</tbody>
			</table>
		</div>
	</div>
	</div>

	<!--_footer 作为公共模版分离出去-->
	<script type="text/javascript" src="lib/jquery/1.9.1/jquery.min.js"></script>
	<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
	<script type="text/javascript" src="static/h-ui/js/H-ui.min.js"></script>
	<script type="text/javascript" src="static/h-ui.admin/js/H-ui.admin.js"></script>
	<!--/_footer 作为公共模版分离出去-->

	<!--请在下方写此页面业务相关的脚本-->
	<script type="text/javascript" src="lib/My97DatePicker/4.8/WdatePicker.js"></script>
	<script type="text/javascript" src="lib/datatables/1.10.0/jquery.dataTables.min.js"></script>
	<script type="text/javascript" src="lib/laypage/1.2/laypage.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/jquery.validate.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/validate-methods.js"></script>
	<script type="text/javascript" src="../lib/jquery.validation/1.14.0/messages_zh.js"></script>
	<script type="text/javascript" src="lib/jquery.cookie.js"></script>
	<script type="text/javascript" src="lib/jquery.query-2.1.7.js"></script>

	<script type="text/javascript">	
		$(function () {
			$("#tab-system").Huitab({
				index: 0
			});
			$('#sioeyeid').keypress(function(e){
				if(e.charCode===13){
					$('#btn_apply').click();
				}
			});
			$('#btn_apply').click(function () {
				$('#list').html('');
				$.ajax({
					type: 'POST',
					url: '/devicelist',
					dataType: 'json',
					data: {
						sioeyeid: $('#sioeyeid').val()
					},
					success: function (retArray) {
						if(retArray.length==0){
							alert("【"+$('#sioeyeid').val()+'】无对应设备数据');
						}
						//console.log(retArray);
						var html = '';
						retArray.forEach(e => {
							//console.log(e);
							var params = {
								'sessiontoken': e.sessiontoken,
								'devicename': e.devicename,
								'deviceid': e.deviceid
							};
							var p = JSON.stringify(params).replace();
							var item = '<tr class="text-c">' +
								'<td>' + e.userid +
								'</td>' +
								'<td>' + e.sioeyeid +
								'</td>' +
								'<td>' + e.deviceid +
								'</td>' +
								'<td>' + e.devicetypeid +
								'</td>' +
								'<td>' + e.devicename +
								'</td>' +
								'<td>' + e.sessiontoken +
								'</td>' +
								'<td>' + getDate(e.createdat) +
								'</td>' +

								'<td class="td-manage"><a href="javascript:void(0);" onclick="stop(' + "'" + e.sessiontoken + "','" + e.deviceid + "','" + e.devicename + "'" + ');">STOP</a>' +
								'</td>' +

								'</tr>';
							html += item;
						});
						$('#list').html(html);
					},
					error: function (d) {
						console.log(d.msg);
					}
				});

			});
		});

		function getDate(d) {
			var nowDate = new Date(d);
			var year = nowDate.getFullYear();
			var month = nowDate.getMonth() + 1 < 10 ? "0" + (nowDate.getMonth() + 1)
				: nowDate.getMonth() + 1;
			var day = nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate
				.getDate();
			var h = nowDate.getHours() < 10 ? "0" + nowDate.getHours() : nowDate
				.getHours();
			var m = nowDate.getMinutes() < 10 ? "0" + nowDate.getMinutes() : nowDate
				.getMinutes();
			var s = nowDate.getSeconds() < 10 ? "0" + nowDate.getSeconds() : nowDate
				.getSeconds();
			var dateStr = year + "-" + month + "-" + day + ' ' + h + ':' + m + ':' + s;
			return dateStr;
		}

		function stop(sessiontoken, deviceid, devicename) {
			console.log(sessiontoken + "-" + deviceid + "-" + devicename);
			$.ajax({
				type: 'POST',
				url: '/stop',
				dataType: 'json',
				data: {
					sessiontoken: sessiontoken,
					deviceid: deviceid,
					devicename: devicename
				},
				success: function (ret) {
					if (ret.success) {
						alert('Command OK');
					}else{
						console.error(ret);
						alert('Command Fail');
					}
				},
				error: function (d) {
					console.log(d.msg);
				}
			})
		};
	</script>
	<!--/请在上方写此页面业务相关的脚本-->
</body>

</html>